<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>js的笔记 | hsd_blog</title>
    <meta name="generator" content="VuePress 1.8.2">
    <link rel="icon" href="/hsd_blog/favicon.ico">
    <meta name="description" content="This is my blog">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/hsd_blog/assets/css/0.styles.95df055c.css" as="style"><link rel="preload" href="/hsd_blog/assets/js/app.99e63b8f.js" as="script"><link rel="preload" href="/hsd_blog/assets/js/3.bc7d3e61.js" as="script"><link rel="preload" href="/hsd_blog/assets/js/1.ca10383e.js" as="script"><link rel="preload" href="/hsd_blog/assets/js/20.49e8f2ea.js" as="script"><link rel="prefetch" href="/hsd_blog/assets/js/10.6d1f0926.js"><link rel="prefetch" href="/hsd_blog/assets/js/11.52a7f5a4.js"><link rel="prefetch" href="/hsd_blog/assets/js/12.fab11c5d.js"><link rel="prefetch" href="/hsd_blog/assets/js/13.07bcd00c.js"><link rel="prefetch" href="/hsd_blog/assets/js/14.2788d2f8.js"><link rel="prefetch" href="/hsd_blog/assets/js/15.cfdfee07.js"><link rel="prefetch" href="/hsd_blog/assets/js/16.d148ece0.js"><link rel="prefetch" href="/hsd_blog/assets/js/17.02756435.js"><link rel="prefetch" href="/hsd_blog/assets/js/18.e3b61e2c.js"><link rel="prefetch" href="/hsd_blog/assets/js/19.2eab3e94.js"><link rel="prefetch" href="/hsd_blog/assets/js/4.3d1d7557.js"><link rel="prefetch" href="/hsd_blog/assets/js/5.a4f99a5f.js"><link rel="prefetch" href="/hsd_blog/assets/js/6.c4eec47d.js"><link rel="prefetch" href="/hsd_blog/assets/js/7.87ee753a.js"><link rel="prefetch" href="/hsd_blog/assets/js/8.c177e54d.js"><link rel="prefetch" href="/hsd_blog/assets/js/9.dcfcd7ec.js">
    <link rel="stylesheet" href="/hsd_blog/assets/css/0.styles.95df055c.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container" data-v-999d3bb4><div data-v-999d3bb4><div id="loader-wrapper" class="loading-wrapper" data-v-2c578df8 data-v-999d3bb4 data-v-999d3bb4><div class="loader-main" data-v-2c578df8><div data-v-2c578df8></div><div data-v-2c578df8></div><div data-v-2c578df8></div><div data-v-2c578df8></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-067bd032 data-v-999d3bb4 data-v-999d3bb4><h3 class="title" data-v-067bd032 data-v-067bd032>hsd_blog</h3> <p class="description" data-v-067bd032 data-v-067bd032>This is my blog</p> <label id="box" class="inputBox" data-v-067bd032 data-v-067bd032><input type="password" value="" data-v-067bd032> <span data-v-067bd032>Konck! Knock!</span> <button data-v-067bd032>OK</button></label> <div class="footer" data-v-067bd032 data-v-067bd032><span data-v-067bd032><i class="iconfont reco-theme" data-v-067bd032></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-067bd032>vuePress-theme-reco</a></span> <span data-v-067bd032><i class="iconfont reco-copyright" data-v-067bd032></i> <a data-v-067bd032><span data-v-067bd032>gui</span>
            
          <span data-v-067bd032>2017 - </span>
          2022
        </a></span></div></div> <div class="hide" data-v-999d3bb4><header class="navbar" data-v-999d3bb4><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/hsd_blog/" class="home-link router-link-active"><img src="/hsd_blog/logo.png" alt="hsd_blog" class="logo"> <span class="site-name">hsd_blog</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/hsd_blog/" class="nav-link"><i class="iconfont reco-home"></i>
  Home
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      Category
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/hsd_blog/categories/李白/" class="nav-link"><i class="undefined"></i>
  李白
</a></li><li class="dropdown-item"><!----> <a href="/hsd_blog/categories/杜甫/" class="nav-link"><i class="undefined"></i>
  杜甫
</a></li><li class="dropdown-item"><!----> <a href="/hsd_blog/categories/jss/" class="nav-link"><i class="undefined"></i>
  jss
</a></li><li class="dropdown-item"><!----> <a href="/hsd_blog/categories/前端知识/" class="nav-link"><i class="undefined"></i>
  前端知识
</a></li></ul></div></div><div class="nav-item"><a href="/hsd_blog/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  Tag
</a></div><div class="nav-item"><a href="/hsd_blog/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  TimeLine
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      Docs
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/hsd_blog/docs/theme-reco/" class="nav-link"><i class="undefined"></i>
  vuepress-reco
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      Contact
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://github.com/recoluan" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-999d3bb4></div> <aside class="sidebar" data-v-999d3bb4><div class="personal-info-wrapper" data-v-e2878dae data-v-999d3bb4><img src="/hsd_blog/avatar.png" alt="author-avatar" class="personal-img" data-v-e2878dae> <h3 class="name" data-v-e2878dae>
    gui
  </h3> <div class="num" data-v-e2878dae><div data-v-e2878dae><h3 data-v-e2878dae>10</h3> <h6 data-v-e2878dae>Articles</h6></div> <div data-v-e2878dae><h3 data-v-e2878dae>3</h3> <h6 data-v-e2878dae>Tags</h6></div></div> <ul class="social-links" data-v-e2878dae></ul> <hr data-v-e2878dae></div> <nav class="nav-links"><div class="nav-item"><a href="/hsd_blog/" class="nav-link"><i class="iconfont reco-home"></i>
  Home
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      Category
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/hsd_blog/categories/李白/" class="nav-link"><i class="undefined"></i>
  李白
</a></li><li class="dropdown-item"><!----> <a href="/hsd_blog/categories/杜甫/" class="nav-link"><i class="undefined"></i>
  杜甫
</a></li><li class="dropdown-item"><!----> <a href="/hsd_blog/categories/jss/" class="nav-link"><i class="undefined"></i>
  jss
</a></li><li class="dropdown-item"><!----> <a href="/hsd_blog/categories/前端知识/" class="nav-link"><i class="undefined"></i>
  前端知识
</a></li></ul></div></div><div class="nav-item"><a href="/hsd_blog/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  Tag
</a></div><div class="nav-item"><a href="/hsd_blog/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  TimeLine
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      Docs
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/hsd_blog/docs/theme-reco/" class="nav-link"><i class="undefined"></i>
  vuepress-reco
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      Contact
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://github.com/recoluan" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><a href="/hsd_blog/" aria-current="page" class="sidebar-link">Home</a></li><li><a href="/hsd_blog/js/js.html" aria-current="page" class="active sidebar-link">js的笔记</a></li></ul> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-067bd032 data-v-999d3bb4><h3 class="title" data-v-067bd032 data-v-067bd032>js的笔记</h3> <!----> <label id="box" class="inputBox" data-v-067bd032 data-v-067bd032><input type="password" value="" data-v-067bd032> <span data-v-067bd032>Konck! Knock!</span> <button data-v-067bd032>OK</button></label> <div class="footer" data-v-067bd032 data-v-067bd032><span data-v-067bd032><i class="iconfont reco-theme" data-v-067bd032></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-067bd032>vuePress-theme-reco</a></span> <span data-v-067bd032><i class="iconfont reco-copyright" data-v-067bd032></i> <a data-v-067bd032><span data-v-067bd032>gui</span>
            
          <span data-v-067bd032>2017 - </span>
          2022
        </a></span></div></div> <div data-v-999d3bb4><main class="page" style="padding-right:0;"><section><div class="page-title"><h1 class="title">js的笔记</h1> <div data-v-10e19382><i class="iconfont reco-account" data-v-10e19382><span data-v-10e19382>gui</span></i> <i class="iconfont reco-date" data-v-10e19382><span data-v-10e19382>1/21/2022</span></i> <!----> <i class="tags iconfont reco-tag" data-v-10e19382><span class="tag-item" data-v-10e19382>js</span></i></div></div> <div class="theme-reco-content content__default"><h3 id="_1-编程语言"><a href="#_1-编程语言" class="header-anchor">#</a> 1.编程语言</h3> <div class="language- extra-class"><pre><code>    机器语言，汇编语言，编程语言
</code></pre></div><h3 id="_2-浏览器执行js简介"><a href="#_2-浏览器执行js简介" class="header-anchor">#</a> 2.浏览器执行js简介</h3> <div class="language- extra-class"><pre><code>    渲染引擎
    js引擎 也成为js解释器 浏览器通过js引擎来执行代码 js为脚本语言
    js的组成 ECMAScript Dom Bom
</code></pre></div><h3 id="_3-注释"><a href="#_3-注释" class="header-anchor">#</a> 3.注释</h3> <div class="language- extra-class"><pre><code>//
/**/
</code></pre></div><h3 id="_4-变量"><a href="#_4-变量" class="header-anchor">#</a> 4 变量</h3> <div class="language- extra-class"><pre><code>    只声明 不赋值结果是undefined
    不声明直接写 
    xx=10;//可以这么写，但是不推荐会变成全局变量
</code></pre></div><h3 id="_5-数据类型"><a href="#_5-数据类型" class="header-anchor">#</a> 5. 数据类型</h3> <div class="language- extra-class"><pre><code>    按照存储空间的不同来划分类型
    弱类型语言，只有在程序运行时才会知道是什么类型的语言
    变量的数据类型是可以变化的
    简单数据类型Number(Nan非数字 ) boolean String Undefined null
    isNan()这个方法判断是不是数字，是数字就返回false，不是返回true
    字符串长度length 拼接 +号
    声明变量未赋值，叫未定义
    null是为空
    boolean相加时算数字1 0
    typeof() 看字符串的类型
    toString()   用+连接转化为字符串
    parseInt() parseFloat() - * /
    Boolean()会转化为布尔形式，只有'' 0 NaN null undefined
</code></pre></div><h3 id="_6-算术运算符"><a href="#_6-算术运算符" class="header-anchor">#</a> 6 算术运算符</h3> <div class="language- extra-class"><pre><code>    表达式和返回值
    递增递减++ --
    比较运算符  ==(会转型)   ===(要求类型和数值都相等)
    表达式1为真则返回表达式2 表达式1为假则返回表达式1(逻辑运算表达式&amp;&amp;)&amp;&amp;优先级高
    表达式1为真则返回表达式1 表达式1为假则返回表达式2(逻辑运算表达式||)
    num +=2;
    三元表达式 条件表达式?表达式1:表达式2
    switch语句
</code></pre></div><h3 id="_7-创建数组"><a href="#_7-创建数组" class="header-anchor">#</a> 7 创建数组</h3> <div class="language- extra-class"><pre><code>    var array = new Array();
    var array1 = [];//数组里可以放任意类型
</code></pre></div><h3 id="_8-function"><a href="#_8-function" class="header-anchor">#</a> 8 function</h3> <div class="language- extra-class"><pre><code>    形参，实参，两个数量不匹配的话，一个是继续运算一个是NaN
    retrun 只能返回一个值，写多了只能返回最后一个值，可以返回数组
    函数没有return的，就返回undefined
    arguments存储了传递过来的所有实参，是一个伪数组
    1.有length属性
    2.有索引方式存储
    3.没有其他数组的方法pop，push
</code></pre></div><h3 id="_9-变量"><a href="#_9-变量" class="header-anchor">#</a> 9 变量</h3> <div class="language- extra-class"><pre><code>    在函数内部没有声明直接赋值的也叫全局变量
    全局变量占内存，直到浏览器关闭才销毁
    局部变量在函数执行完就销毁
    作用域链        链式查找：内部函数访问外部函数的变量，（就近原则）
</code></pre></div><h3 id="_10-预解析-js解释器先预解析然后代码执行"><a href="#_10-预解析-js解释器先预解析然后代码执行" class="header-anchor">#</a> 10 预解析        js解释器先预解析然后代码执行</h3> <div class="language- extra-class"><pre><code>            会把var和function提升到js的最前面
            然后按照代码从上到下执行

            变量提升和函数提升
            变量提升（把变量声明提升到当前作用域的最前面）
            函数提升就把函数提升到当前作用域的最前面
</code></pre></div><h3 id="_11对象"><a href="#_11对象" class="header-anchor">#</a> 11对象</h3> <div class="language- extra-class"><pre><code>            构造函数把对象里面的相同的属性和方法封装起来
</code></pre></div><h3 id="_12内置对象"><a href="#_12内置对象" class="header-anchor">#</a> 12内置对象</h3> <div class="language- extra-class"><pre><code>            Math 不是构造函数，直接使用即可
            Math.PI
            Date()日期对象
            var date= new Date
            date.getMonth() 返回当前的月，但要加一
</code></pre></div><h3 id="_13-innertext-不识别标签"><a href="#_13-innertext-不识别标签" class="header-anchor">#</a> 13 innerText 不识别标签</h3> <div class="language- extra-class"><pre><code>innerHtml 识别标签
</code></pre></div><h3 id="_14-element-style-backgroundcolor-pink-style里的属性-采用驼峰式"><a href="#_14-element-style-backgroundcolor-pink-style里的属性-采用驼峰式" class="header-anchor">#</a> 14 element.style.backgroundColor=&quot;pink&quot;; style里的属性，采用驼峰式</h3> <div class="language- extra-class"><pre><code>js修改后是行内的，权重高
</code></pre></div><h3 id="_15-element-classname-修改类名"><a href="#_15-element-classname-修改类名" class="header-anchor">#</a> 15 element.className 修改类名</h3> <div class="language- extra-class"><pre><code>            this.className=&quot;change change2&quot; 给他两个类名
</code></pre></div><h3 id="_16判断当前的环境"><a href="#_16判断当前的环境" class="header-anchor">#</a> 16判断当前的环境</h3> <div class="language- extra-class"><pre><code>    console.log(typeof window===&quot;undefined&quot;?&quot;node:&quot;:&quot;browser&quot;);
    console.log(Object.is(1));
</code></pre></div></div></section> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">3/13/2022, 9:40:59 PM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev"><a href="/hsd_blog/" class="prev router-link-active">
            Home
          </a></span> <!----></p></div> <div class="comments-wrapper"><!----></div> <ul class="side-bar sub-sidebar-wrapper" style="width:0;" data-v-92abcef6></ul></main> <!----></div></div></div></div><div class="global-ui"><!----><!----></div></div>
    <script src="/hsd_blog/assets/js/app.99e63b8f.js" defer></script><script src="/hsd_blog/assets/js/3.bc7d3e61.js" defer></script><script src="/hsd_blog/assets/js/1.ca10383e.js" defer></script><script src="/hsd_blog/assets/js/20.49e8f2ea.js" defer></script>
  </body>
</html>
